/*
 * @Author: fjt
 * @Date: 2021-07-07 21:25:33
 * @LastEditors: fjt
 * @LastEditTime: 2021-07-07 22:40:49
 */
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

module.exports = {
  lintOnSave: false,
  devServer: {
    open: true,
    overlay: {
      warnings: true,
      errors: true
    }
  },
  publicPath: '/assets/admin',
  filenameHashing: true,
  productionSourceMap: false,
  configureWebpack: config => {
    config.optimization.splitChunks = {
      cacheGroups: {
        common: {
          name: 'commom',
          minChunks: 2,
          priority: -20,
          chunks: 'initial',
          reuseExistingChunk: true
        },
        vendors: {
          name: 'vendors',
          test: /[\\/]node_modules[\\/]/,
          chunks: 'initial',
          priority: -10
        }
      }
    };

    if (process.env.BUNDLE_ANALYZER === 'YES') {
      return {
        plugins: [new BundleAnalyzerPlugin()]
      };
    }
  },
  chainWebpack: config => {}
};
